package jalus;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import freemarker.template.Template;
import freemarker.template.TemplateException;

public abstract class Action{

	public void doGet(HttpServletRequest req, HttpServletResponse resp)throws IOException{}

	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException{}
	
	public void error(){};
	
	public void processTemplate(Map<String, Object> root, 
			String templatePath, HttpServletResponse resp) throws IOException{
		Template template = FMConfigureFactory.getFMConfigure().getTemplate(templatePath);
        resp.setCharacterEncoding("utf-8"); 
        resp.setContentType("text/html; charset=UTF-8");
        PrintWriter out = resp.getWriter();
        try {
        	template.process(root, out);
		} catch (TemplateException e) {
			e.printStackTrace();
		}
        out.flush();
	}
}
